package org.example.entity.requestbody;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * "keyFilters": [
 *     {
 *       "key": {
 *         "key": "firstError",
 *         "type": "TIME_SERIES"
 *       },
 *       "valueType": "STRING",
 *       "predicate": {
 *         "operation": "EQUAL",
 *         "value": {
 *           "defaultValue": "",
 *           "dynamicValue": null
 *         },
 *         "type": "STRING"
 *       }
 *     }
 *   ]
 */

@Component
@Data
@NoArgsConstructor
@AllArgsConstructor
public class KeyFilter<T> {
    private Key key;
    private String valueType;
    private Predicate<T> predicate;

    public KeyFilter(String keyName,String keyType,String valueType,String predicateType,String operation,T defaultValue,String dynamicValue){
        this.key=new Key(keyName,keyType);
        this.valueType=valueType;
        Value<T> predicateValue=new Value<>(defaultValue,dynamicValue);
        this.predicate=new Predicate<>(predicateType,operation,predicateValue);
    }
}
@Data
@AllArgsConstructor
@NoArgsConstructor
class Key{
    private String key;
    private String type;
}
@Data
@AllArgsConstructor
@NoArgsConstructor
class Predicate<T>{
    private String type;
    private String operation;
    private Value<T> value;
}
@Data
@AllArgsConstructor
@NoArgsConstructor
class Value<T>{
    private T defaultValue;
    private String dynamicValue;
}